package com.lyf.viewapp.multimedia;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.lyf.viewapp.R;
import com.lyf.viewapp.base.BaseActivity;
import com.lyf.viewapp.chart.LineChartActivity;
import com.lyf.viewapp.chart.PieChartActivity;
import com.lyf.viewapp.util.EnterBean;
import com.lyf.viewapp.util.EnterRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 多媒体主页
 *
 * @author lyf
 * @date 2018年10月18日 14:48:14
 */
public class MultiMediaMainActivity extends BaseActivity {

    @BindView(R.id.multi_media_list)
    RecyclerView multiMediaList;

    private List<EnterBean> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_media_main);
        ButterKnife.bind(this);


        list = new ArrayList<>();
        initDate();
    }


    private void initDate() {
        list.add(new EnterBean("PieChart", PieChartActivity.class));
        list.add(new EnterBean("LineChart", LineChartActivity.class));

        multiMediaList.setLayoutManager(new LinearLayoutManager(this));
        EnterRecyclerAdapter adapter = new EnterRecyclerAdapter(R.layout.main_item, list);
        adapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
        adapter.bindToRecyclerView(multiMediaList);
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = new Intent(MultiMediaMainActivity.this, list.get(position).getActivity());
                startActivity(intent);
            }
        });
    }
}
